home *** CD-ROM | disk | FTP | other *** search
/ Gurewich OLE Controls for Visual Basic 4 / Gurewich OLE Controls for Visual Basic 4.iso / ocxprog / programs / ch13 / speaker2.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1995-08-24  |  12.4 KB  |  400 lines

  1. VERSION 4.00
  2. Begin VB.Form frmSpeaker 
  3.    Caption         =   "The Speaker Program"
  4.    ClientHeight    =   3375
  5.    ClientLeft      =   1155
  6.    ClientTop       =   1545
  7.    ClientWidth     =   7575
  8.    Height          =   4065
  9.    Icon            =   "SPEAKER2.frx":0000
  10.    Left            =   1095
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   3375
  13.    ScaleWidth      =   7575
  14.    Top             =   915
  15.    Width           =   7695
  16.    Begin VB.CommandButton cmdFast 
  17.       Caption         =   "&Fastest"
  18.       Height          =   435
  19.       Left            =   6720
  20.       TabIndex        =   10
  21.       Top             =   1620
  22.       Width           =   735
  23.    End
  24.    Begin VB.CommandButton cmdNormal 
  25.       Caption         =   "&Normal"
  26.       Height          =   435
  27.       Left            =   2280
  28.       TabIndex        =   9
  29.       Top             =   1620
  30.       Width           =   735
  31.    End
  32.    Begin VB.CommandButton cmdSlow 
  33.       Caption         =   "S&lowest"
  34.       Height          =   435
  35.       Left            =   120
  36.       TabIndex        =   8
  37.       Top             =   1620
  38.       Width           =   735
  39.    End
  40.    Begin VB.HScrollBar hsbSpeed 
  41.       Height          =   255
  42.       Left            =   120
  43.       Max             =   200
  44.       Min             =   50
  45.       TabIndex        =   5
  46.       Top             =   1320
  47.       Value           =   100
  48.       Width           =   7335
  49.    End
  50.    Begin VB.CommandButton cmdRewind 
  51.       Caption         =   "&Rewind"
  52.       Height          =   855
  53.       Left            =   5880
  54.       TabIndex        =   4
  55.       Top             =   2400
  56.       Width           =   1575
  57.    End
  58.    Begin VB.CommandButton cmdPlayMultitask 
  59.       Caption         =   "Play &MultiTask"
  60.       Height          =   855
  61.       Left            =   2040
  62.       TabIndex        =   3
  63.       Top             =   2400
  64.       Width           =   1575
  65.    End
  66.    Begin VB.CommandButton cmdStop 
  67.       Caption         =   "&Stop"
  68.       Height          =   855
  69.       Left            =   3960
  70.       TabIndex        =   2
  71.       Top             =   2400
  72.       Width           =   1575
  73.    End
  74.    Begin VB.CommandButton cmdPlay 
  75.       Caption         =   "&Play"
  76.       Height          =   855
  77.       Left            =   120
  78.       TabIndex        =   1
  79.       Top             =   2400
  80.       Width           =   1575
  81.    End
  82.    Begin VB.Label lblSpeed 
  83.       Caption         =   "Speed: 100"
  84.       BeginProperty Font 
  85.          name            =   "MS Sans Serif"
  86.          charset         =   0
  87.          weight          =   400
  88.          size            =   12
  89.          underline       =   0   'False
  90.          italic          =   0   'False
  91.          strikethrough   =   0   'False
  92.       EndProperty
  93.       Height          =   300
  94.       Left            =   120
  95.       TabIndex        =   7
  96.       Top             =   960
  97.       Width           =   1935
  98.    End
  99.    Begin TegoswLibCtl.Tegosw swExit 
  100.       Height          =   630
  101.       Left            =   0
  102.       TabIndex        =   6
  103.       Top             =   0
  104.       Width           =   525
  105.       _version        =   65536
  106.       _extentx        =   926
  107.       _extenty        =   1111
  108.       _stockprops     =   64
  109.       value           =   -1  'True
  110.    End
  111.    Begin MSComDlg.CommonDialog CommonDialog1 
  112.       Left            =   1800
  113.       Top             =   120
  114.       _Version        =   65536
  115.       _ExtentX        =   847
  116.       _ExtentY        =   847
  117.       _StockProps     =   0
  118.       CancelError     =   -1  'True
  119.    End
  120.    Begin TegspkrLib.TegoSpeaker TegoSpeaker1 
  121.       Height          =   600
  122.       Left            =   720
  123.       TabIndex        =   0
  124.       Top             =   120
  125.       Width           =   930
  126.       _version        =   65536
  127.       _extentx        =   1640
  128.       _extenty        =   1058
  129.       _stockprops     =   0
  130.    End
  131.    Begin VB.Menu mnuFile 
  132.       Caption         =   "&File"
  133.       Begin VB.Menu mnuOpen 
  134.          Caption         =   "&Open..."
  135.          Enabled         =   0   'False
  136.       End
  137.       Begin VB.Menu mnuClose 
  138.          Caption         =   "&Close"
  139.          Enabled         =   0   'False
  140.       End
  141.       Begin VB.Menu mnuPlay 
  142.          Caption         =   "&Play"
  143.       End
  144.       Begin VB.Menu mnuSep1 
  145.          Caption         =   "-"
  146.       End
  147.       Begin VB.Menu mnuInfo 
  148.          Caption         =   "&Info..."
  149.       End
  150.       Begin VB.Menu mnuSep2 
  151.          Caption         =   "-"
  152.       End
  153.       Begin VB.Menu mnuExit 
  154.          Caption         =   "E&xit"
  155.       End
  156.    End
  157.    Begin VB.Menu mnuHelp 
  158.       Caption         =   "&Help"
  159.       Begin VB.Menu mnuAbout 
  160.          Caption         =   "About..."
  161.       End
  162.    End
  163. Attribute VB_Name = "frmSpeaker"
  164. Attribute VB_Creatable = False
  165. Attribute VB_Exposed = False
  166. ' All variables must be declared.
  167. Option Explicit
  168. Private Sub cmdFast_Click()
  169. ' Set the hsbSpeed scrollbar to its maximum value.
  170. hsbSpeed.Value = hsbSpeed.Max
  171. End Sub
  172. Private Sub cmdNormal_Click()
  173. ' Set the hsbSpeed scrollbar to a value of 100.
  174. hsbSpeed.Value = 100
  175. End Sub
  176. Private Sub cmdPlay_Click()
  177. ' Play from the beginning of the WAV file until
  178. ' the end of the WAV file without multitasking,
  179. ' and disable the mouse during playback.
  180. TegoSpeaker1.Play 0, -1, 0, False
  181. End Sub
  182. Private Sub cmdPlayMultitask_Click()
  183. ' Play from the current playback position until
  184. ' the end of the WAV file, with a 300 milliseconds
  185. ' multitask interval, and enable the mouse during
  186. ' playback.
  187. TegoSpeaker1.Play -1, -1, 300, True
  188. End Sub
  189. Private Sub cmdRewind_Click()
  190. ' Rewind the playback position to the beginning
  191. ' of the WAV file.
  192. TegoSpeaker1.Seek 0
  193. End Sub
  194. Private Sub cmdSlow_Click()
  195. ' Set the hsbSpeed scrollbar to its minimum value.
  196. hsbSpeed.Value = hsbSpeed.Min
  197. End Sub
  198. Private Sub cmdStop_Click()
  199. ' Stop the playback.
  200. TegoSpeaker1.Stop
  201. End Sub
  202. Private Sub Form_Load()
  203.    Dim Path
  204.    Dim Filename
  205.    TegoSpeaker1.Visible = False
  206.   ' Get the name of the directory where the
  207.   ' program resides.
  208.   Path = App.Path
  209.   If Right(Path, 1) <> "\" Then
  210.      Path = Path + "\"
  211.   End If
  212.  ' Initially, no WAV file is open, so we execute the
  213.  ' mnuClose_Click() procedure to disable various
  214.  ' controls.
  215.  '''  mnuClose_Click
  216.     ' Open the WAV file.
  217.     Filename = Path + "PEOPLEOF.WAV"
  218.     TegoSpeaker1.Open Filename
  219.     ' If Open command failed, exit this procedure.
  220.     If TegoSpeaker1.GetErrorCode <> 0 Then
  221.        MsgBox TegoSpeaker1.GetErrorMessage
  222.        End
  223.     End If
  224.     ' Display the name of the WAV file (without the path).
  225.     Me.Caption = "The Speaker Program - PeopleOf.WAV"
  226.     ' A WAV file is now open, so enable
  227.     ' the Speed, Close, Info, Play, Stop,
  228.     ' and Rewind controls.
  229.     hsbSpeed.Enabled = True
  230.     cmdSlow.Enabled = True
  231.     cmdFast.Enabled = True
  232.     cmdNormal.Enabled = True
  233.     'mnuClose.Enabled = True
  234.     mnuInfo.Enabled = True
  235.     cmdPlay.Enabled = True
  236.     cmdPlayMultitask.Enabled = True
  237.     cmdStop.Enabled = True
  238.     cmdRewind.Enabled = True
  239.     ' Set the Speed scrollbar to normal speed.
  240.     hsbSpeed.Value = 100
  241. End Sub
  242. Private Sub hsbSpeed_Change()
  243.    ' Updtae the lblSpeed label with the new value of
  244.    ' the hsbSpeed scrollbar.
  245.    lblSpeed.Caption = "Speed: " + Str(hsbSpeed.Value)
  246.    ' Change the playback speed to the speed specified
  247.    ' by the hsbSpeed scrollbar.
  248.    TegoSpeaker1.SetSpeed hsbSpeed.Value
  249. End Sub
  250. Private Sub hsbSpeed_Scroll()
  251.    ' Execute the hsbSpeed_Change() procedure.
  252.    hsbSpeed_Change
  253. End Sub
  254. Private Sub mnuAbout_Click()
  255.    Dim Title
  256.    Dim Msg
  257.    Dim CR
  258.    CR = Chr(13) + Chr(10)
  259.    ' The title of the About message box.
  260.    Title = "About the Speaker Program"
  261.    ' Prepare the message of the About message box.
  262.    Msg = "This program was written with Visual "
  263.    Msg = Msg + "Basic for Windows, using the "
  264.    Msg = Msg + "TegoSoft Speaker OCX control. "
  265.    Msg = Msg + CR + CR
  266.    Msg = Msg + "The TegoSoft Speaker OCX control "
  267.    Msg = Msg + "is part of the TegoSoft OCX Control "
  268.    Msg = Msg + "Kit - a collection of various OCX controls. "
  269.    Msg = Msg + CR + CR
  270.    Msg = Msg + "For more information about the "
  271.    Msg = Msg + "TegoSoft OCX Control Kit, contact TegoSoft "
  272.    Msg = Msg + "at:"
  273.    Msg = Msg + CR + CR
  274.    Msg = Msg + "TegoSoft Inc." + CR
  275.    Msg = Msg + "P.O. Box 389" + CR
  276.    Msg = Msg + "Bellmore, NY 11710"
  277.    Msg = Msg + CR + CR
  278.    Msg = Msg + "Phone: (516)783-4824"
  279.    ' Display the About message box.
  280.    MsgBox Msg, vbInformation, Title
  281. End Sub
  282. Private Sub mnuClose_Click()
  283.     ' Close the WAV file.
  284.     TegoSpeaker1.Close
  285.     ' No WAV file is now open, so disable
  286.     ' the Speed, Close, Info, Play, Stop,
  287.     ' and Rewind controls.
  288.     hsbSpeed.Enabled = False
  289.     cmdSlow.Enabled = False
  290.     cmdFast.Enabled = False
  291.     cmdNormal.Enabled = False
  292.     mnuClose.Enabled = False
  293.     mnuInfo.Enabled = False
  294.     cmdPlay.Enabled = False
  295.     cmdPlayMultitask.Enabled = False
  296.     cmdStop.Enabled = False
  297.     cmdRewind.Enabled = False
  298.     ' Set the title of the program's window.
  299.     Me.Caption = "The Speaker Program"
  300. End Sub
  301. Private Sub mnuExit_Click()
  302. ' Terminate the program.
  303. Unload Me
  304. End Sub
  305. Private Sub mnuInfo_Click()
  306. Dim Title
  307. Dim Msg
  308. Dim CRLF
  309. CRLF = Chr(13) + Chr(10)
  310. ' The title of the Info message box.
  311. Title = "WAV File Information"
  312. ' Prepare the message for the Info message box.
  313. Msg = "File Name: " + TegoSpeaker1.GetWavFilename
  314. Msg = Msg + CRLF
  315. Msg = Msg + "File Length: " + Str(TegoSpeaker1.GetLength) + " samples."
  316. Msg = Msg + CRLF
  317. Msg = Msg + "Sampling Rate: " + Str(TegoSpeaker1.GetSamplingRate) + " Hz."
  318. Msg = Msg + CRLF
  319. Msg = Msg + "Number of Bits Per Sample: " + Str(TegoSpeaker1.GetNumBits)
  320. Msg = Msg + CRLF
  321. Msg = Msg + "Number of Channels: " + Str(TegoSpeaker1.GetNumChannels)
  322. ' Display the Info message box.
  323. MsgBox Msg, vbInformation, Title
  324. End Sub
  325. Private Sub mnuOpen_Click()
  326.     ' Set an error trap to detect the clicking
  327.     ' of the Cancel key of the Open dialog box.
  328.     On Error GoTo OpenError
  329.     ' Fill the items of the File Type list box of
  330.     ' the Open dialog box.
  331.     CommonDialog1.Filter = "All Files (*.*)|*.*|Wave Files (*.wav)|*.wav"
  332.     ' Set the default File Type to Wave Files (*.wav).
  333.     CommonDialog1.FilterIndex = 2
  334.     ' Display the Open dialog box.
  335.     CommonDialog1.Action = 1
  336.     ' Remove the error trap.
  337.     On Error GoTo 0
  338.     ' Open the WAV file that the user selected.
  339.     TegoSpeaker1.Open CommonDialog1.Filename
  340.     ' If Open command failed, exit this procedure.
  341.     If TegoSpeaker1.GetErrorCode <> 0 Then
  342.        MsgBox "Cannot open " + CommonDialog1.Filename, 0, "ERROR"
  343.        MsgBox TegoSpeaker1.GetErrorMessage
  344.        mnuClose_Click
  345.        Exit Sub
  346.     End If
  347.     ' Display the name of the WAV file (without the path).
  348.     Me.Caption = "The Speaker Program - " + CommonDialog1.FileTitle
  349.     ' A WAV file is now open, so enable
  350.     ' the Speed, Close, Info, Play, Stop,
  351.     ' and Rewind controls.
  352.     hsbSpeed.Enabled = True
  353.     cmdSlow.Enabled = True
  354.     cmdFast.Enabled = True
  355.     cmdNormal.Enabled = True
  356.     mnuClose.Enabled = True
  357.     mnuInfo.Enabled = True
  358.     cmdPlay.Enabled = True
  359.     cmdPlayMultitask.Enabled = True
  360.     cmdStop.Enabled = True
  361.     cmdRewind.Enabled = True
  362.     ' Set the Speed scrollbar to normal speed.
  363.     hsbSpeed.Value = 100
  364.     ' Exit the procedure.
  365.     Exit Sub
  366. OpenError:
  367.     ' The user clicked the Cancel button of the
  368.     ' Open File dialog box.
  369.     Exit Sub
  370. End Sub
  371. Private Sub mnuPlay_Click()
  372. cmdPlay_Click
  373. End Sub
  374. Private Sub swExit_Click()
  375.    Dim Title
  376.    Dim Question
  377.    Dim Response
  378.    ' If the user turned the swExit switch OFF,
  379.    ' confirm that the user wants to exit the
  380.    ' program, and if so, exit the program.
  381.    If swExit.Value = False Then
  382.       Title = "Exit Program"
  383.       Question = "Are you sure you want to exit?"
  384.       Response = MsgBox(Question, vbYesNo + vbQuestion, Title)
  385.       If Response = vbYes Then
  386.          Unload Me
  387.       Else
  388.          swExit.Value = True
  389.       End If
  390.    End If
  391. End Sub
  392. Private Sub TegoSpeaker1_Done()
  393. ' If current playback position is end of file,
  394. ' rewind the playback position to the beginning of
  395. ' the file.
  396. If TegoSpeaker1.GetPosition = TegoSpeaker1.GetLength Then
  397.    TegoSpeaker1.Seek 0
  398. End If
  399. End Sub
  400.